package com.gmm.springboot.admin.service.test01.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmm.springboot.admin.mapper.test01.UserInfo;
import com.gmm.springboot.admin.mapper.test01.UserInfoMapper;
import com.gmm.springboot.admin.service.test01.UserInfoService;

@Service
public class UserInfoServiceImpl implements UserInfoService {
	@Autowired
	private UserInfoMapper userInfoMapper;

	public void addRecord(UserInfo record) {
		if (record == null) {
			return;
		}

		Date now = new Date();

		userInfoMapper.addRecord(record);
	}

	public List<UserInfo> findRecordsByMap(Map<String, Object> whereParams, int beginIndex, int maxCount) {
		if (whereParams == null) {
			whereParams = new HashMap<String, Object>(0);
		}

		whereParams.put("beginIndex", beginIndex);
		whereParams.put("maxCount", maxCount);

		return userInfoMapper.findSelectRecordByMap(whereParams);
	}

	public void updateRecord(UserInfo record) {
		if (record == null) {
			return;
		}

		Date now = new Date();

		userInfoMapper.updRecord(record);
	}

	public void deleteRecord(Integer userId) {
		if (userId == null) {
			return;
		}

		userInfoMapper.delRecord(userId);
	}

	public int findRecordCount(Map<String, Object> whereParams) {
		return userInfoMapper.findRecordsCount(whereParams);
	}

	public UserInfo findRecordByKey(Integer userId) {
		if (userId == null) {
			return null;
		}

		return userInfoMapper.findRecordByKey(userId);
	}

}
